import {triggerHighlightElemClick} from "~contents/hoverTools";

const show = (highlightId) => {
  console.log("inside show...");
  const highlightEl = document.querySelector(`[data-highlight-id="${highlightId}"]`);
  if (highlightEl) {
    highlightEl.scrollIntoViewIfNeeded(true);

    const boundingRect = highlightEl.getBoundingClientRect();

    document.dispatchEvent(new CustomEvent('highlightElemClicked', {
      detail: {
        elem: highlightEl,
        clientX: boundingRect.left + (boundingRect.width / 2),
      }
    }));
    // const boundingRect = highlightEl.getBoundingClientRect();
    // // TODO: Move some of this logic to hoverTools:
    // onHighlightMouseEnterOrClick({
    //   'type': 'click',
    //   'target': highlightEl,
    //   'clientX': boundingRect.left + (boundingRect.width / 2),
    // });
  }
}

export default show;
